< previous page page_358 next page >

Page 358
LISTING 16.2.CONTINUED
9f8044bafea36a1f728739c0bb58ef4c.gif
32:    Next lRow
33: End Sub
34:
35: Private Sub isTimeToPrint(argReportDate As Date, _ argReportTime As  Date)
36:    'Incoming arguments represent Date and Time passed in
37:    Dim dReportDate As Date, dReportTime As Date
38:    Dim sReportName As String
39:    For lRow = 1 To theFlexGrid.Rows
40:      theFlexGrid.Row = lRow
41:      theFlexGrid.Col = 3
42:      dReportDate = theFlexGrid.Text
43:      theFlexGrid.Col = 4
44:      dReportTime = theFlexGrid.Text
45:      If argReportDate = dReportDate And
46:      argReportTime = dReportTime Then
47:         theFlexGrid.Col = 2
48:         sReportName = theFlexGrid.Text
49:         printReport sReportName
50:    Next lRow
51:
52: End Sub
53:
54: Private Sub printReport(argReportName As String)
55:      'Send the report name to the actual reporting class
56:      'responsible for getting and printing reports
57:      theReporting.printReport argReportName
58: End Sub
59:
60: Private Sub theTimer_Timer()
61:     'Periodically invoke isTimeToPrint()
62:     isTimeToPrint Date, Time
63: End Sub

Notice the scheduleReport method. It is compatible with all of the grid controls Visual Basic supports. But the MSFlexGrid control has an AddItem method that would have simplified the code as follows:
theFlexGrid.AddItem lCount & vbTab & argReportName & vbTab & argReportDate _
     & vbTab & argReportTime, lCount
Then the method cancelReport would look like
theFlexGrid.RemoveItem argReportID
Designing your application to incorporate ad hoc reporting capabilities, at a minimum, requires that you accept a query from the user. The user need not be a standard query language (SQL) expert, but if the user does not know SQL, you must incorporate a query

 
< previous page page_358 next page >

If you like this book, buy it!